<?php 
include "../inc-config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Account Creation</title>
<style type="text/css">
<!--
body {
background-color: #000000;
background-image: url(../images/alliance-tile.jpg); background-repeat:repeat-x;
}
body,td,th {
color: #CC9900;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
a:link {
color:#CC9900; 

}
a:visited {
color:#CC9900;

}
a:hover {
color:#ffffff;
}
a:active {
color:#FF0000;


}
input { background:transparent; background-image:url(../images/transp.png); color:#FFFFFF; border: 1px solid #333333}
select { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}
textarea { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}

-->
</style>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
$bademail=0; //trackers for banned e-mails
$email=$_POST['email'];
$email=strip_tags($email);
$email=trim($email);
$getbademails="SELECT * from b_banemails";
$getbademails2=mysql_query($getbademails) or die("Could not grab bad emails");
while($getbademails3=mysql_fetch_array($getbademails2))
{
if(substr_count($email,$getbademails3[email])>0)
{
$bademail++;
}
}
if($bademail>0)
{
die("<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'><tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr><tr><td><center>That email is banned from registering</center></td></tr></table>");
}
$valid=1;
$username=$_POST['username'];
$username=strip_tags($username);
$username=trim($username);
$password=$_POST['password'];
$password=trim($password);
$password=strip_tags($password);



$signature=$_POST['signature'];
$signature=trim($signature);
$pass2=$_POST['pass2'];
$usercheck="SELECT*from b_users where username='$username' or email='$email'";
$usercheck2=mysql_query($usercheck);
while ($usercheck3=mysql_fetch_array($usercheck2))
{
$valid=0;
}
if($valid==0)
{
print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
print "<tr><td><center>";  
print "That username has been taken or there is already someone registered with that email or you did not enter email,<br> please <A href='register.php'>try to register again</a>. (or hit back)";
print "</td></tr></table></center>";
}
else if(substr_count($username," ")>0)
{
die("Spaces are not allowed in names");
}
else if(!preg_match("^[A-Za-z0-9]+$^", "$username"))
{
print "There were invalid characters in the username.";
}   
else if(strlen($username)>15 || strlen($username)<3)
{
print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
print "<tr><td><center>";  
die("Username must be between 3 and 15 characters in length");
print "</center></td></tr></table>";
}
else if(strlen($email)<4 || substr_count($email," ")>0)
{
die("<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'><tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr><tr><td>You did not enter an email or email has not valid format.</center></td></tr></table>"); 
}
else
{
if ($password==$pass2 && $_POST['password'])
{
$password2=md5($password);
$supervalue=$value;
$day=date("U");
$email=$_POST['email'];
$location=$_POST['location'];
$aim=$_POST['aim'];
$showprofile=$_POST['showprofile'];
$icq=$_POST['icq'];

$a2=$_POST['a2'];
$a=$_POST['a'];
$ref=$_POST['ref'];

$seedval=$day%100000;
srand($seedval);
$key=RAND(1000000,2000000);
if($requirekey=="no"||$requirekey=="No") //if you do no require an activation key
{
//*********UPDATE REFF TABLES1*****************
if ($a2=="a") {$SQLfriends="update b_friends set link1='0' where userid='$ref'";}
if ($a2=="b") {$SQLfriends="update b_friends set link2='0' where userid='$ref'";}
if ($a2=="c") {$SQLfriends="update b_friends set link3='0' where userid='$ref'";}
if ($a2=="d") {$SQLfriends="update b_friends set link4='0' where userid='$ref'";}
if ($a2=="e") {$SQLfriends="update b_friends set link5='0' where userid='$ref'";}
$SQLfriends2=mysql_query($SQLfriends) or die("Error: ".mysql_error());
$getuser="SELECT * from b_users where userID='$ref'";
$getuser2=mysql_query($getuser) or die("Could not get user info");
$getuser3=mysql_fetch_array($getuser2);
$numnow=$getuser3[friend]-1; $numpoints=$getuser3[points]+10; $numrep=$getuser3[honours]+15;
$SQLfr="update b_users set friend='$numnow', honours='$numrep', points='$numpoints' where userID='$ref'";
mysql_query($SQLfr) or die(mysql_error());
//********************************************
$SQL ="INSERT into b_users (username,password,email,validated,location,AIM,ICQ,showprofile,points) values('$username','$password2','$email','1','$location','$aim','$icq','$showprofile','10')";
mysql_query($SQL) or die(mysql_error());
$SQLwow ="INSERT into accounts (login,password,gm,banned,lastip,email,flags,forceLanguage) values ('$username','$pass2','','0','".$_SERVER['REMOTE_ADDR']."','$email','8','enUS')";
mysql_query($SQLwow) or die(mysql_error());
}
else //you require an activation key
{
//*********UPDATE REFF TABLES2*****************
if ($a2=="a") {$SQLfriends="update b_friends set link1='0' where userid='$ref'";}
if ($a2=="b") {$SQLfriends="update b_friends set link2='0' where userid='$ref'";}
if ($a2=="c") {$SQLfriends="update b_friends set link3='0' where userid='$ref'";}
if ($a2=="d") {$SQLfriends="update b_friends set link4='0' where userid='$ref'";}
if ($a2=="e") {$SQLfriends="update b_friends set link5='0' where userid='$ref'";}
$SQLfriends2=mysql_query($SQLfriends) or die("Error: ".mysql_error());
$getuser="SELECT * from b_users where userID='$ref'";
$getuser2=mysql_query($getuser) or die("Could not get user info");
$getuser3=mysql_fetch_array($getuser2);
$numnow=$getuser3[friend]-1; $numpoints=$getuser3[points]+10; $numrep=$getuser3[honours]+15;
$SQLfr="update b_users set friend='$numnow', honours='$numrep', points='$numpoints' where userID='$ref'";
mysql_query($SQLfr) or die(mysql_error());
//********************************************
$SQL ="INSERT into b_users (username,password,sig, keynode,email,location,AIM,ICQ,showprofile) values('$username','$password2','$signature','$key','$email','$location','$aim','$icq','$showprofile')";
mysql_query($SQL) or die(mysql_error());
$SQLwow ="INSERT into accounts (login,password,gm,banned,lastip,email,flags,forceLanguage) values ('$username','$pass2','','0','".$_SERVER['REMOTE_ADDR']."','$email','8','enUS')";
mysql_query($SQLwow) or die(mysql_error());
mail("$email","Your forum activation key","Paste the URL to activate your account.  $boardpath/activate.php?username=$username&password=$password&keynode=$key");

} 
print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
print "<tr><td style='background-image: url(../images/transpblack.png)'><center><strong><font style='color: #00CC00'>Success! Way to go!</font></strong></center></td></tr>";
print "<tr><td>";
if($requirekey=="no"||$requirekey=="No")
{
print "<center>Forum and Server account are created!<br>You can now login to server with your username and password.<br><br>You have been awarded with +10 points. <br> You mast wait 10 mins until server account become active.<br><br><strong><font color='white'>set realmlist mystika-wow.com</font></strong></center><br><br>";
print "";
print "<tr><td style='background-image: url(../images/transp.png)'><center>Your username is $username.<br>Your password is $pass2.</center></td></tr>";

print "<tr><td style='background-image: url(../images/transpblack.png)'><center><A href='login.php'>Click here to Login</a></center></td></tr>";
}
else
{
print "Forum registration completed please check your email for activation key. Go <A href='login.php'>here to Login</a>.";
}
if($notifyme=="Yes" || $notifyme=="yes")
{
mail("$adminemail","Registration at $sitetitle forums","This is just to inform you that $username has just registered in your forums");
}
print "</td></tr></table>";
}
else
{
print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
print "<tr><td><center>"; 
print "Your passwords didn't match or you did not enter a password";
print "</center></td></tr></table>";
}
}
}
?>
</body>
</html>

